<% if flash[:notice]  -%>
  <div class="sysmsg"><%= flash[:notice] -%></div>
  <% flash[:notice] = nil -%>
<% end -%>
<table id="columns">
  <tr>
    <!-- Main Messages -->
    <td id="main">
      <div id="content">
        <div id="stream" class="message">
          <h3>What are the others doing?</h3>
          <ol class="wa">
            <% @messages.each do |message| -%>
              <% users = User.find(:all, :conditions => ["id='#{message.user_id}'"]) -%>
                <% users.each do |user| -%>
                  <% next if user.privacy == 'T' -%>
                  <li class=unlight>
                    <%= link_to(image_tag(user.avatar, :alt => user.display_name).to_s, {:controller => :message, :action => :user, :id => user.id}, :class => "avatar", :title => user.display_name) -%>
                    <%= link_to(user.display_name, {:controller => :message, :action => :user, :id => user.id}, :title => user.display_name) -%>
                    <span class="content"><%= message.content -%></span>
                    <span class="stamp"><%= link_to("Posted about " + time_string(Time.now.to_i - message.post_at.to_i) + " ago", {:controller => :message, :action => "show", :id => message.id}, :class => "time") -%></span>
                    <span class="op">
                    <% if session[:user_name] != nil and session[:user_name] != user.name-%>
                      <%= link_to("Add to favorite", {:controller => :favorite, :action => "add", :id => message.id}, :class => "post_act share") -%>
                    <% end -%>
                    <% if session[:user_name] == user.name  -%>
                        <% session[:ori_uri] = request.request_uri -%>
                        <%= link_to("Delete", {:controller => :message, :action => "delete", :id => message.id}, :class => "delete", :confirm => "Do you really want to delete this message?") -%>
                    <% end -%>
                    </span>
                  </li>
                <% end -%>
            <% end -%>
          </ol>
        </div>
      </div>
    </td>
    
    <!-- Sidebar -->
    <!-- All the following values will be replaced by varibles -->
    <td id="sidebar">
      <div class="sect first-sect">
        <% unless session[:user_name] -%>
          <% form_tag({:controller => :login, :action => :index},
              :method => :post) do -%>
            <p>
              <label for="name" class="label_input">Name: </label>
              <%= text_field_tag :name, params[:name], :size => 32 -%>
            </p>
            <p>
              <label for="user_password" class="label_input">Password: </label>
              <%= password_field_tag :password, params[:password], :size => 32-%>
            </p>
            <p class="act">
              <%= submit_tag "Login", :class => "formbutton" -%>
            </p>
          <% end -%>
        <% end -%>
      </div>
      <div class="sect <%= session[:user_name].nil? ? "" : "first-sect" -%>">
        <h2>Anouncements</h2>
        <ul>
          <li>Some Anouncements</li>
        </ul>
      </div>
      <div class="sect">
        <h2>Widgets</h2>
        <ul>
          <li>Some widgets</li>
        </ul>
      </div>
      <div class="sect">
        <h2>More...</h2>
        <ul>
          <li>Something More.</li>
        </ul>
      </div>
    </td>
  </tr>
</table>